package com.yodawnla.attackTitan2;

import org.anddev.andengine.entity.Entity;
import org.anddev.andengine.entity.sprite.Sprite;

import com.yodawnla.attackTitan2.system.Fonts;
import com.yodawnla.attackTitan2.system.Hud;
import com.yodawnla.attackTitan2.system.Tex;
import com.yodawnla.lib.YoActivity;
import com.yodawnla.lib.hud.YoHudMgr;
import com.yodawnla.lib.util.widget.YoButton;
import com.yodawnla.lib.util.widget.YoText;

public class WarringWindow 
{
	public static WarringWindow getInstance()
	{
		if (instance == null)
			instance = new WarringWindow();
		return instance;
	}
	static WarringWindow instance;
	
	Sprite mWindowSprite;
 	YoText mWindowText;
 	 
	IOnClickListener mListener;

	WarringWindow()
	{
		Entity layer = YoHudMgr.getInstance().createHudLayer(Hud.Window, 2);
		hide();
		
		mWindowSprite = new Sprite(52, 248, YoActivity.getBaseActivity().getTexture(Tex.Window));
		layer.attachChild(mWindowSprite);
		mWindowText = new YoText(35, 30, Fonts.WHITE25, "Now Text is empty",50);
		mWindowSprite.attachChild(mWindowText);
		
//		Sprite windowSprite ...layer
		YoButton confirmBtn = new YoButton(YoHudMgr.getInstance().getHud(), 132, 161, YoActivity.getBaseActivity().getTexture(Tex.Button))
		{
			public void onClickedEvent()
			{
				if (mListener != null)
					mListener.onClickedEvent();
				hide();
			}
		};
		mWindowSprite.attachChild(confirmBtn);
	}
	
	public void showWindow(String text)
	{
		showWindow(text, null);
	}
	
	public void showWindow(String text, IOnClickListener listener)
	{
		mListener = listener;
		mWindowText.setText(text);
		YoHudMgr.getInstance().showHudLayer(Hud.Window);
	}
	
	
	public void hide()
	{
		YoHudMgr.getInstance().hideHudLayer(Hud.Window);
	}
	
	public interface IOnClickListener
	{
		public void onClickedEvent();
	}
}
